﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StorePrgram.Data
{
    static class StoreDBDataManager
    {
        public static Product GetProductByID(int id)
        {
            StoreDBDataClassesDataContext dc = new StoreDBDataClassesDataContext();
            Product[] productsArray;

            productsArray = (Product[])((from products in dc.GetTable<Product>()
                       where (products.ProductId == id)
                       select products).ToArray<Product>());

            if (productsArray.Length > 0)
            {
                return productsArray[0];
            }

            return null;
        }
    }
}
